{include file='Public/header' /}
<div class="layui-layout layui-layout-admin">
{include file='Public/head' /}	
{include file='Public/side' /}	
	<div class="layui-body"> 
{include file='Public/crumbs' /}
<style>
.hidden{ display:none;}
</style>
		<!-- 内容主体区域 -->
		<div class="shu-body">
			<div class="layui-fluid">
				<form class="layui-form layui-form-pane" action="" method="post">
				<input name="id" value="{notempty name='currentcategory'}{$currentcategory.id}{/notempty}" type="hidden">
				<input name="classid" id="classid" value="{$pid}" type="hidden">
				<div class="layui-form-item" style="display:none;">
					<label class="layui-form-label">栏目类型</label>
				  	<div class="layui-input-block">
					<select id="type" name="type" lay-verify="required" lay-filter="test">
						<option value="0"
						{notempty name='currentcategory'}{if condition="$currentcategory['type'] eq 0"}selected="selected"{/if}{/notempty}
						>普通栏目</option>
						<option value="1"
						{notempty name='currentcategory'}{if condition="$currentcategory['type'] eq 1"}selected="selected"{/if}{/notempty}
						>单页栏目</option>
						<option value="2"
						{notempty name='currentcategory'}{if condition="$currentcategory['type'] eq 2"}selected="selected"{/if}{/notempty}
						>外链栏目</option>
					</select>
				    </div>
				</div>
				<div class="layui-form-item" {notempty name='id'} style="d_isplay:none;" {/notempty}>
				  	<label class="layui-form-label">父类</label>
				  	<div class="layui-input-block">
					<select id="pid" name="pid">
						{if condition="!$pid"}
						<option value="0">总分类</option>
						{/if}
                        {$category}
                    </select>
				  	</div>
				</div>
				<div class="layui-form-item">
				  	<label class="layui-form-label">分类名称</label>
				  	<div class="layui-input-inline">
					<input type="text" name="name" id="name" placeholder="分类名称" class="layui-input" value="{notempty name='currentcategory'}{$currentcategory.name}{/notempty}" required lay-verify="required" autocomplete="off" class="layui-input">
				  	</div>
					<div class="layui-form-mid layui-word-aux">分类名称，不能为空。</div>
				</div>
				<div class="layui-form-item" style="display:none;">
				  	<label class="layui-form-label">目录名称</label>
				  	<div class="layui-input-block">
					<input type="text" name="dir" id="dir" placeholder="请输入目录名称如: 'news'  (不包含单引号及空格) " class="layui-input" value="{notempty name='currentcategory'}{$currentcategory.dir}{/notempty}" class="layui-input">
				  	</div>
				</div>
				<div class="layui-form-item">
				  	<label class="layui-form-label">SEO标题</label>
				  	<div class="layui-input-block">
					<input type="text" name="seotitle" id="seotitle" placeholder="SEO标题" value="{notempty name='currentcategory'}{$currentcategory.seotitle}{/notempty}" class="layui-input">
				  	</div>
				</div>
				<div class="layui-form-item">
				  	<label class="layui-form-label">SEO关键词</label>
				  	<div class="layui-input-block">
					<input type="text" name="keywords" id="keywords" placeholder="关键词" value="{notempty name='currentcategory'}{$currentcategory.keywords}{/notempty}" class="layui-input">
				  	</div>
				</div>
				<div class="layui-form-item layui-form-text">
				  	<label class="layui-form-label">栏目描述</label>
				  	<div class="layui-input-block">
					<textarea name="description" id="description" placeholder="栏目描述" class="layui-textarea" >{notempty name='currentcategory'}{$currentcategory.description}{/notempty}</textarea>
				  	</div>
				</div>
				
				<div id="type2" class="{notempty name='currentcategory'}{if condition=" $currentcategory['type'] neq 2"}hidden{/if}{/notempty}">
					<div class="layui-form-item" style="display:none;">
						<label class="layui-form-label">外链地址</label>
						<div class="layui-input-block">
						<input type="text" name="url" id="url" placeholder="外链地址" value="{notempty name='currentcategory'}{$currentcategory.url}{/notempty}" class="layui-input">
						</div>
					</div>
				</div>
				
				<div id="type1" class="{notempty name='currentcategory'}{if condition=" $currentcategory['type'] neq 1"}hidden{/if}{/notempty}">
					<div class="layui-form-item layui-form-text" style="display:none;">
						<label class="layui-form-label">文章内容</label>
						<div class="layui-input-block">
						<textarea name="content" id="content" placeholder="文章内容" class="layui-textarea" >{notempty name='currentcategory'}{$currentcategory.content}{/notempty}</textarea>
						</div>
					</div>
				</div>
				
				<div class="layui-form-item" style="display:none;">
				  	<label class="layui-form-label">分类模板</label>
				  	<div class="layui-input-block">
					<input type="text" name="cattemplate" id="cattemplate" placeholder="分类模板" value="{notempty name='currentcategory'}{$currentcategory.cattemplate}{/notempty}" class="layui-input">
				  	</div>
				</div>
				<div class="layui-form-item" style="display:none;">
				  	<label class="layui-form-label">内容模板</label>
				  	<div class="layui-input-block">
					<input type="text" name="contemplate" id="contemplate" placeholder="内容模板" value="{notempty name='currentcategory'}{$currentcategory.contemplate}{/notempty}" class="layui-input">
				  	</div>
				</div>
				<div class="layui-form-item">
				  	<label class="layui-form-label">排序</label>
				  	<div class="layui-input-inline">
					<input type="number" name="o" id="o" placeholder="排序" class="layui-input" value="{notempty name='currentcategory'}{$currentcategory.o}{/notempty}" class="layui-input">
				  	</div>
					<div class="layui-form-mid layui-word-aux">数字越大越靠前</div>
				</div>
				<div class="layui-form-item">
				  <div class="layui-input-block">
					<button class="layui-btn" lay-submit="" lay-filter="formDemo">立即提交</button>
					<button type="reset" class="layui-btn layui-btn-primary">重置</button>
				  </div>
				</div>
			  </form>
			</div>
		</div>
		<!-- 内容主体区域 END-->
	</div>
{include file='Public/footer' /}	
<script>
layui.use(['form','layer'], function(){
	var form = layui.form,jq = layui.$,layer=layui.layer;
	//监听下拉
	form.on('select(test)', function(data){
	  console.log(data.value);
		if (data.value == 1) {
			jq("#type1").removeClass('hidden');
			jq("#type2").addClass('hidden');
		} else if (data.value == 2) {
			jq("#type2").removeClass('hidden');
			jq("#type1").addClass('hidden');
		} else {
			jq("#type1").addClass('hidden');
			jq("#type2").addClass('hidden');
		}
	});
	
	form.on('submit(formDemo)', function(data){
		loading = layer.load(2, {
			shade: [0.2,'#000']
		});
		var param = data.field;
		jq.post("{:url('update')}",param,function(data){
			console.log(data);
			if(data.code == 1){
				layer.close(loading);
				layer.msg(data.msg, {icon: 1, time: 1000}, function(){
					//location.reload();
					//location.href="{:url('index')}";
					location.href=data.url;
				});
			}else{
				layer.close(loading);
				layer.msg(data.msg, {icon: 2, anim: 6, time: 1000});
			}
		});
	return false;
	});
	
	
	

	
});
</script>